-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swapped all numpy assert_allclose & assert_array_equal to pytest approx in tests #780
base: develop
Are you sure you want to change the base?
Conversation
@@ -793,7 +792,7 @@ def test_getitem(self, ref, growth): | |||
def test_iter(self, ref, growth): | |||
Cat = bh.axis.StrCategory if isinstance(ref[0], str) else bh.axis.IntCategory | |||
a = Cat(ref, growth=growth) | |||
assert_array_equal(a, ref) | |||
assert a == approx(ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert a == approx(ref) | |
assert np.asarray(a) == approx(ref) |
Quick fix. But is it possible to control how pytest treats approx?
Why do you replace the numpy assserts with pytest.approx? The messages produced by numpy.assert_allclose etc are better than those from pytest.approx, and numpy.assert_allclose works on array-like types, too. |
I believe this came up while working on the comparison issue but I don't remember the exact details on why! @henryiii do you want to chime in here? |
Addresses 2c81964 commit further.
I realized that there are other asserts that are imported directly which I missed in previous commit, so this covers all of them.